package Tree;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class item103 {
    public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
        Queue<Integer> queue = new LinkedList<>();
        List<List<Integer>> res = new ArrayList<>();
        List<Integer> track = new ArrayList<>();
        boolean flag = false;
        queue.add(root.val);
        TreeNode tmp = root;
        while (!queue.isEmpty())
        {   
            Integer num = queue.poll();
            track.add(num);
            if(flag&&tmp.left!=null) queue.add(tmp.left.val);
            if(flag&&tmp.right!=null) queue.add(tmp.right.val);
            if(flag==false&&tmp.right!=null) queue.add(tmp.right.val);
            if(flag==false&&tmp.left!=null) queue.add(tmp.left.val);

        }
        return null;
    }
}
